﻿namespace UnityEditor
{
    using System;
    using UnityEngine;

    [Serializable]
    internal class AnimBool : AnimValue
    {
        [SerializeField]
        private float m_Value;

        public AnimBool()
        {
            this.m_Value = 0f;
        }

        public AnimBool(bool val)
        {
            this.m_Value = !val ? 0f : 1f;
        }

        public float Fade(float from, float to)
        {
            return Mathf.Lerp(from, to, this.faded);
        }

        public static implicit operator bool(AnimBool v)
        {
            return (v.m_Value > 0.5f);
        }

        internal override void Update()
        {
            this.m_Value = Mathf.Lerp((float) base.m_Source, !this.target ? 0f : 1f, base.smoothed);
        }

        public float faded
        {
            get
            {
                return this.m_Value;
            }
        }

        public bool target
        {
            get
            {
                return (Convert.ToSingle(base.GetTarget(this.m_Value)) > 0.5f);
            }
            set
            {
                base.BeginAnimating(!value ? 0f : 1f, this.m_Value);
            }
        }

        public bool value
        {
            get
            {
                return (this.m_Value > 0.5f);
            }
            set
            {
                this.m_Value = !value ? 0f : 1f;
                base.StopAnim(value);
            }
        }
    }
}

